package _2022.contest.biweekly.biweekly_contest_75;

/**
 * @author： YHSimon
 * @date： 2022-04-02 22:56
 */
public class Solution2 {
    public int triangularSum(int[] nums) {
        int len=nums.length;
        int curLen=len;
        int epoch=0;
        while(epoch<len){
            epoch++;
            for(int i=0;i<curLen-1;i++){
                nums[i]=(nums[i]+nums[i+1])%10;
            }
            curLen--;
        }

        return nums[0];
    }

    public static void main(String[] args) {
        Solution2 s = new Solution2();
        System.out.println(s.triangularSum(new int[]{1, 2, 3, 4, 5}));
        System.out.println(s.triangularSum(new int[]{5}));
    }
}
